All Questions
Tagged with graph-traversaltrees
6 questions
1vote
1answer
220views
How to apply Graphs/Trees/BFS/DFS concepts to Lists
I have been doing problems on LeetCode recently, and keep getting stuck on some graph or tree problems. I understand the underlying concepts of Graphs, Trees, and different methods of traversal just ...
1vote
1answer
54views
Modified graph traversal
This question is most easy to describe as a modification of that my question. Suppose that question is solved as the following Python class: class Traversal(object): # ... def next(self): # ...
0votes
2answers
284views
Breadth-first traversal with some edges preferred
Let we have a (finite or infinite) directed graph and a start vertex. For each vertex we have the set of edges from this vertex totally ordered to specify the traversal order. Let we also have a set P ...
4votes
1answer
567views
Is this Wikipedia pseudocode for in-order generic tree traversal correct?
Wikipedia states that the following algorithm works for any tree (not necessarily binary trees) Perform pre-order operation For each i (with i = 1 to n) do: Visit i-th, if present ...
1vote
1answer
2kviews
In which of the following tree traversal all the child nodes are visited first before the parent node [closed]
In an n-ary tree... Given a reference to some child node And a reference to a distant parent of the referenced child node Is there a method that a parent node can use to figure out which of its ...
22votes
4answers
44kviews
Is Pre-Order traversal same as Depth First Search?
It seems to me like pre-order traversal and DFS are same as in both the cases we traverse from root till the left branch and back to root and then to the right branch recursively. Could any please ...